var a = require("../../../@babel/runtime/helpers/objectWithoutProperties"), t = require("../../../@babel/runtime/helpers/defineProperty"), e = [ "url" ], i = getApp();

Page({
    data: {
        activeName: 0,
        dataList: [],
        titleArr: [ {
            name: "我送出的",
            url: "plugin.warehouse.frontend.controllers.gift.records.give"
        }, {
            name: "我领取的",
            url: "plugin.warehouse.frontend.controllers.gift.records.receive"
        } ],
        isLoadMore: !0
    },
    onLoad: function(a) {
        1 == a.tag && this.setData({
            activeName: 1
        });
    },
    init: function() {
        this.data.dataList = [ {
            loading: !1,
            finished: !1,
            refreshing: !1,
            page: 1,
            list: [],
            url: "plugin.warehouse.frontend.controllers.gift.records.give"
        }, {
            loading: !1,
            finished: !1,
            refreshing: !1,
            page: 1,
            list: [],
            url: "plugin.warehouse.frontend.controllers.gift.records.receive"
        } ];
    },
    handleClick: function(a) {
        this.setData({
            activeName: a.detail.name
        }), 0 == this.data.dataList[this.data.activeName].list.length && this.getData();
    },
    getData: function() {
        var a = this, e = i.getNetAddresss(this.data.dataList[this.data.activeName].url);
        i._postNetWork({
            url: e,
            data: {
                page: this.data.dataList[this.data.activeName].page
            },
            success: function(e) {
                var i = e.data;
                if (a.data.dataList[a.data.activeName].loading = !1, 1 == i.result) {
                    a.data.dataList[a.data.activeName].isLoadMore = !0, a.data.dataList[a.data.activeName].page = a.data.dataList[a.data.activeName].page + 1;
                    var s = a.data.dataList[a.data.activeName].list;
                    a.setData(t({}, "dataList[" + a.data.activeName + "].list", s.concat(i.data.data))), 
                    i.data.last_page == i.data.current_page && (a.data.dataList[a.data.activeName].finished = !0);
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    toUrl: function(a) {
        var t = a.currentTarget.dataset || {};
        this.wxRouterLink(t);
    },
    wxRouterLink: function(t) {
        var i = "", s = t.url, n = a(t, e);
        Object.keys(n).forEach(function(a) {
            "" !== n[a] && (i += a + "=" + n[a] + "&");
        }), "" !== s && wx.navigateTo({
            url: s + "?" + i.slice(0, -1)
        });
    },
    onReady: function() {},
    onShow: function() {
        this.init(), this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        console.log(this.data.dataList[this.data.activeName].loading, this.data.dataList[this.data.activeName].finished), 
        this.data.dataList[this.data.activeName].loading || this.data.dataList[this.data.activeName].finished || this.getData();
    },
    onShareAppMessage: function() {}
});